// 引入api
import { reqUserAddress, reqTradeInfo } from '@/api';

const state = {
    address: [],
    tradeInfo:{}
};
const mutations = {
    GETUSERADDRESS: (state, address) => {
        state.address = address;
    },
    GETTRADEINFO:(state, tradeInfo) => {
        state.tradeInfo = tradeInfo;
    }
};
const actions = {
    getUserAddress: async ({ state, commit, dispatch }) => {
        let result = await reqUserAddress();
        if (result.code == 200) {
            commit("GETUSERADDRESS", result.data)
        }
    },
    getTradeInfo:async({state, commit, dispatch})=>{
        let result = await reqTradeInfo();
        if (result.code== 200) {
            commit('GETTRADEINFO', result.data)
        }
    }
};

const getters = {};

export default {
    state,
    mutations,
    actions,
    getters
}
